/*
 * Created on 2005-1-28
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.sohu.sip.auth.util;

import java.util.Collection;
import java.util.Iterator;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;


import com.sohu.peak.util.HibernateHelper;
import com.sohu.peak.util.PeakSessionFactory;
import com.sohu.sip.auth.constant.OuterSystemTypeStatus;
import com.sohu.sip.auth.constant.PeakModuleName;
import com.sohu.sip.auth.po.Config;

/**
 * @author luciali
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ConfigParameter {
	protected static String getConfigParamter(String name) {
		String value = "";
        Session session=null;
        Transaction tx=null;
    
        session = PeakSessionFactory.instance().getCurrentSession();
            //tx=session.beginTransaction();
    		RunManager manager=RunManager.getInstance();
            
    		Object [] object = new Object[3];
            object[0] = name;
            object[1] = manager.getRunStatus().getServerName();
            object[2] = new Integer(OuterSystemTypeStatus.STATUS_NORMAL);
            Collection c = HibernateHelper.query(session, "com.sohu.rdapp.sip.sysadmin.business.bean.ConfigBean.findParamter", object);
            if ((c != null) && (c.size() > 0)) {
            	Iterator it = c.iterator();
            	if ((it != null) && (it.hasNext())) {
            		Config config = (Config)it.next();
            		value = config.getValue();
            	}
            }
            
            session.flush();
           
    

        if (value == null) value = "";
		return value;
	}
}
